package com.lm.auth.entity;

import cn.hutool.json.JSONObject;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Map;

@Data
public class AuthUser implements UserDetails {

    private Integer id;
    private String account;
    private String name;
    private String password;

    public AuthUser(Map<String,Object> userMap) {
        this.id= (Integer) userMap.get("id");
        this.account= String.valueOf(userMap.get("account"));
        this.name= String.valueOf(userMap.get("name"));
        this.password= String.valueOf(userMap.get("password"));
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.account;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
